package com.shujushow.chapter01.config;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created by xinshu on 2016/3/31.
 */
@Configuration
public class ListenerConfiguration {
    private static Log logger = LogFactory.getLog(ListenerConfiguration.class);

    @Bean
    protected ServletContextListener listener(){
        return new ServletContextListener() {
            public void contextInitialized(ServletContextEvent servletContextEvent) {
                logger.info("ServletContext initialized");
                logger.debug("debug--------------------------------------------------------------");
            }

            public void contextDestroyed(ServletContextEvent servletContextEvent) {
                logger.info("ServletContext destroyed");
            }
        };
    }
}
